package com.foreknow.elm.controller;

import com.foreknow.elm.po.Business;
import com.foreknow.elm.service.BusinessService;
import com.foreknow.elm.service.impl.BusinessServiceImpl;

import javax.servlet.http.HttpServletRequest;
import java.util.List;


public class BusinessController {
    /**
     * 根据orderTypeId查询商家的信息
     * http://localhost:8089//MavenElmWebProject/BusinessController/listBusinessByOrderTypeId?orderTypeId=1
     * @param request
     * @return
     */
    public Object listBusinessByOrderTypeId(HttpServletRequest request) {
        //获取请求的参数  BusinessController/listBusinessByOrderTypeId?orderTypeId=1
        Integer orderTypeId = Integer.valueOf(request.getParameter("orderTypeId"));
        //调用Service的方法
        BusinessService service = new BusinessServiceImpl();
        List<Business> list = service.listBusinessByTypeId(orderTypeId);
        return list;
    }

    /**
     * 根据businessId查询某一个商家的信息
     * @param request
     * @return
     */
    public Object getBusinessById(HttpServletRequest request) {
        Integer businessId = Integer.valueOf(request.getParameter("businessId"));
        BusinessService service = new BusinessServiceImpl();
        Business business = service.getBusinessById(businessId);
        return business;
    }
}
